<template>
  <div class="box" id="quanxianZongheInfo">
    <div v-if="flag==1">
      <div class="display_flex box_search">
        <div class="display_flex margin_rignt">
          <p>权利人姓名：</p>
          <div>
            <el-input placeholder="请输入"></el-input>
          </div>
        </div>
        <div class="display_flex margin_rignt">
          <p>复垦片块：</p>
          <div>
            <el-select v-model="value" placeholder="请选择">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </div>
        </div>
        <div class="display_flex margin_rignt">
          <p>开始时间：</p>
          <div>
            <el-date-picker v-model="value" type="date" placeholder="选择日期"></el-date-picker>
          </div>
        </div>
        <div class="display_flex margin_rignt">
          <p>截止时间：</p>
          <div>
            <el-date-picker v-model="value" type="date" placeholder="选择日期"></el-date-picker>
          </div>
        </div>
        <el-button type="primary">查询</el-button>
      </div>
      <div class="table">
        <el-table :data="dataArr" border style="width: 100%" v-loading="isListLoading">
          <el-table-column type="index" show-overflow-tooltip label="序号" width="80"></el-table-column>
          <el-table-column prop="applicantName" label="权利人"></el-table-column>
          <el-table-column prop="landName" label="验收地块"></el-table-column>
          <el-table-column prop="place" label="位置"></el-table-column>
          <el-table-column prop="time" label="验收时间"></el-table-column>
          <el-table-column label="操作" fixed="right">
             <template slot-scope="scope">
            <!-- <template> -->
              <el-button size="mini" type="primary" @click="btnById(scope.row)">查看</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="pages">
        <el-pagination
          @size-change="showSize"
          @current-change="showPage"
          :current-page="needInfo.page"
          :page-sizes="[5, 10, 20, 400]"
          :page-size="needInfo.size"
          layout="total, sizes, prev, pager, next, jumper"
          :total="totalPage"
        ></el-pagination>
      </div>
    </div>
    <div class="landInfo" v-if="flag==2">
      <div class="back">
        <el-button icon="el-icon-back" size="small" @click="flag=1">返回</el-button>
      </div>
      <div class="title">
        <p class="title_one">{{landData.landName}}</p>
        <p class="title_little">
          <span>综合验收时间：{{landData.time}}</span>
        </p>
      </div>
      <div class="project_position">
        <div class="project_title">综合验收结果</div>
        <div class="project_result">
          <div class="display_flex">
            <p>验收结果：</p>
            <el-checkbox v-model="checked" disabled>通过验收</el-checkbox>
          </div>
        </div>
      </div>
      <div class="project_position">
        <div class="project_title">综合验收现场位置及轨迹</div>
        <div class="project_img">
          <!-- <img src="../../../assets/mapText.png" width="500" height="400" /> -->
          <tdMap style="height: 600px" class="mapBox_right" ref="tdMap" :pkList="mainDataData" :isShowControls="false" />
        </div>
      </div>
      <div class="project_position">
        <div class="project_title">综合验收资料</div>
        <div class="project_img">
          <el-table :data="imgArr" border style="width: 100%">
            <el-table-column type="index" show-overflow-tooltip label="序号" width="60"></el-table-column>
            <el-table-column prop="name" label="类型" width="200"></el-table-column>
            <el-table-column label="操作">
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="primary"
                  fixed="left"
                  @click="btnSeeImg(scope.row)"
                >查看</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
    </div>

    <el-dialog :title="title" :before-close="handleClose" :visible.sync="seeImgDialog" width="50%">
      <div class="seeImg">
        <div class="imgBox" style="width:500px;height:500px;margin:0 auto;" v-if="showImgType==1">
          <img style="width:100%;height:100%;" :src="$https+titlePath" alt="">
        </div>
        <div class="imgBox" style="width:700px;height:400px;margin:0 auto;" v-if="showImgType==2">
          <video id="showVedio" autoplay controls style="width:100%;height:100%;" :src="$https+titlePath"></video>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  supervisingInfo,
  supervisingCheck
} from "@/api/quxianzongheYanshou";
import { getLandStatusMapAuditInfo } from "@/api/jjgc";
import tdMap from "@/components/tdMap";
export default {
  components: {
    tdMap
  },
  data() {
    return {
      checked: true,
      flag: 1,
      options: [
        {
          value: "0",
          label: "全部"
        },
        {
          value: "1",
          label: "莲花村片区片块7-1"
        },
        {
          value: "2",
          label: "莲花村片区片块7-2"
        }
      ],
      value: "",
      tableData: [
        {
          date: "",
          name: "",
          address: ""
        },
        {
          date: "",
          name: "",
          address: ""
        }
      ],
      currentPage4: 4,
      title: "",
      titlePath: '',
      seeImgDialog: false,
      imgArr: [],


      dataArr:[],
      needInfo:{
        page:1,
        size:5
      },
      totalPage:0,
      landId:'',
      landData:null, //单条监管详情
      showImgType:null, //分辨视频图片

      isListLoading:false,
      mainDataData:[],
    };
  },
  created(){
    this.getData()
  },
  methods: {
    handleClose(){
      this.seeImgDialog=false
      var vedio=document.getElementById("showVedio")
      vedio.currentTime = 0
      vedio.pause()
    },
    btnById(row){
      console.log(row,"单条数据")
      if(row.yesOrNo=="YES"){
        this.checked=true
      }else{
        this.checked=false
      }
      this.landId=row.landId
      var data1={
        landId:row.landId,
      }
      getLandStatusMapAuditInfo(data1).then(res=>{
        let obj=res.data
        let array=[]
        array.push(obj)
        this.mainDataData=array
      })
      this.landData=row
      var obj={
        page:1,
        size:10,
        photo:row.photo?row.photo:'',
        vcr:row.vcr?row.vcr:''
      }
      supervisingCheck(obj).then(res=>{
        console.log(res,'监管详情')
        var imageGeShi=["bmp","pcx","png","jpg","jpeg","gif","tiff"]
        var videoGeShi=["mp4","avi","flv","rmvb","mkv","gif","mov","rm","3gp"]
        var mainList=[]
        var mainList1=[]
        res.data.rows.forEach((item,index)=>{
          imageGeShi.forEach(item1=>{
            if(item.fileKey.substring(item.fileKey.indexOf('.')+1,item.fileKey.length)==item1){
              mainList.push({name:'外业核查照片',path:item.filePath,type:1})
            }
          })
        })
        res.data.rows.forEach((item,index)=>{
          videoGeShi.forEach(item1=>{
            if(item.fileKey.substring(item.fileKey.indexOf('.')+1,item.fileKey.length)==item1){
              mainList1.push({name:'核查现场视频',path:item.filePath,type:2})
            }
          })
        })
        //名称处理
        mainList.forEach((item,index)=>{
          item.name=item.name+(index!=0?index:'')
        })
        mainList1.forEach((item,index)=>{
          item.name=item.name+(index!=0?index:'')
        })
        this.imgArr=mainList.concat(mainList1)

        this.flag=2
      })
    },
    getData(){
      let obj={
        projectId:localStorage.getItem("projectId"),
        page:this.needInfo.page,
        size:this.needInfo.size,
        landId:'',
        applicantName:''
      }
      this.isListLoading=true
      supervisingInfo(obj).then(res=>{
        this.isListLoading=false
        console.log(res,'res')
        this.dataArr=res.data.rows
        this.totalPage=res.data.total
      }).catch(error => {
          this.isListLoading=false
        });
    },
    showSize(val) {
      console.log(`每页 ${val} 条`);
      this.needInfo.size = val;
      this.getData();
    },
    showPage(val) {
      console.log(`当前页: ${val}`);
      this.needInfo.page = val;
      this.getData();
    },
    btnSeeImg(row) {
      this.title = row.name;
      this.titlePath = row.path
      this.showImgType = row.type
      this.seeImgDialog = true;
      var vedio=document.getElementById("showVedio")
      vedio.play()
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    }
  }
};
</script>

<style scoped>
.box {
  padding: 30px;
}
.display_flex {
  display: flex;
  align-items: center;
}
.box_search .display_flex p {
  font-size: 14px;
  color: #333333;
}
.margin_rignt {
  margin-right: 30px;
}
.table {
  margin: 20px 0px;
}

.landInfo {
  border: 1px solid #efefef;
  box-sizing: border-box;
}
.back {
  margin: 20px;
}
.title_one {
  text-align: center;
  line-height: 40px;
  font-size: 20px;
  color: #444;
  font-weight: bold;
}
.title_little {
  font-size: 13px;
  color: #999;
  margin: 40px 20px 20px 30px;
}
.title .title_little span {
  margin-right: 30px;
}
.project_title {
  background: #f8f8f8;
  height: 50px;
  background: #f8f8f8;
  padding: 0px 30px;
  line-height: 50px;
  color: #48494d;
  font-size: 14px;
  font-weight: bold;
  border-top: 1px solid #efefef;
  border-bottom: 1px solid #efefef;
}
.project_img {
  padding: 30px;
}
.seeImg {
  text-align: center;
}
.project_result {
  padding: 30px;
}
.project_result .display_flex {
  margin-bottom: 20px;
  font-size: 13px;
  color: #444;
  width: 180px;
}
.project_result .display_flex p {
  font-size: 14px;
  color: #444444;
  font-weight: bold;
}
#quanxianZongheInfo >>> .el-checkbox__input.is-disabled+span.el-checkbox__label{
  border-color: #409EFF;
}
#quanxianZongheInfo >>> .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner{
  border-color: #409EFF;
background-color: #409EFF;
}
#quanxianZongheInfo >>> .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner::after{
  border-color: #fff;
}
#quanxianZongheInfo >>> .el-checkbox__input.is-disabled+span.el-checkbox__label{
  color: #12203e;
}
.pages{
  text-align: center;
}
.mapBox_right{
  width: 950px;
  margin-top:30px; 
}
</style>